//
// ModuleManager.h
// Usage: Manage all startup-loaded kernel modules
// CreateDate: 2009-04-09
// Author: MaJiuyue
//
#ifndef _MODULEMANAGER_H_
#define _MODULEMANAGER_H_

#include "type.h"
#include "Map.h"
#include "UString.h"
#include "Multiboot.h"
#include "Module.h"
#include "SCI.h"

class CModuleManager : public Callable
{
private:
	Map<String, Module *, 64> m_KernelModules;

public:
	/* Init module manager, add all startup-module to it */
	CModuleManager(addr_t mods_addr, int mods_count);
	~CModuleManager();

public:
	/* Add a kernel module */
	bool AddModule(module_t * ko);
	
	/* Delete kernel module `strModuleName', if not exist, return false. */
	bool DelModule(String &strModuleName) 
	{ panic("Not Implement ModuleManager::DelModule()."); }

	/* Get a module descriptor by name */
	Module * GetModule(const char * strModuleName)
	{ return m_KernelModules.lookup(String(strModuleName)); }

	/* Get a module descriptor by index */
	Module * GetModuleByIndex(unsigned int index)
	{ return m_KernelModules.getByIndex(index); }
	
	/* Get modules count */
	unsigned int GetModuleCount() { return m_KernelModules.length(); }
};

#endif

